package com.superhelper.app.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.superhelper.app.domain.BuyOrder;

public interface PayMapper {

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into buy_order(buyOrderCode,orderType,orderName,oriMoney,discMoney,money,payed,orderFrom,userType,uid,state,stateMsg,ip,createAt)values("
            + "#{buyOrderCode},#{orderType},#{orderName},#{oriMoney},#{discMoney},#{money},#{payed},#{orderFrom},#{userType},#{uid},"
            + "#{state},#{stateMsg},#{ip},current_timestamp)")
    int addBuyOrder(BuyOrder bo);

    @Select("select * from buy_order where id = #{value}")
    BuyOrder getBuyOrder(Long buyOrderId);

    @Update("update buy_order set state=#{state},stateMsg=#{stateMsg},payed=#{payed} where id=#{id} and state< #{state}")
    int updateBuyOrder(BuyOrder bo);

    @Select("select * from buy_order where buyOrderCode = #{value}")
    BuyOrder getBuyOrderByCode(String buyOrderCode);
}
